package model

import (
	"database/sql/driver"
	"encoding/json"
	"gorm.io/gorm"
	"time"
)

type GormList []string

func (j *GormList) Scan(value interface{}) error {
	return json.Unmarshal(value.([]byte), &j)
}

// 实现 driver.Valuer 接口，Value 返回 json value
func (j GormList) Value() (driver.Value, error) {
	return json.Marshal(j)
}

type BaseModel struct {
	ID        int32     `gorm:"primarykey;type(int)"`
	CreatedAt time.Time `gorm:"column:add_time"`
	UpdatedAt time.Time `gorm:"column:update_time"`
	DeletedAt gorm.DeletedAt
	IsDeleted bool
}
